//index.js
//获取应用实例
const app = getApp();
//授权页面
Page({
  data: {
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },

  onLoad: function () {
  },

  getUserInfo: function (e) {
    var that = this;
    wx.getUserInfo({
      success: function (resUser) {
        var objz = {
          avatarUrl: resUser.userInfo.avatarUrl,
          nickName: resUser.userInfo.nickName
        };
        //存储userInfo
        wx.setStorageSync(app.userInfoKey, objz); 
        //获取微信用户在缓存中存储的openid信息，判断是否正确的获取微信用户的信息
        app.getUserInfo();
        wx.reLaunch({
          url: "../../pages/index/index"
        });
      }
    });
  }

})